<?php
	include("../../include/dbconnect.php");
	extract($_POST);
	$strdk=" where id=$id";
	if($id=="") $strdk="";

	$table="dghang";
	$table_title="đơn giá cho hàng";
	$table_title_u="Đơn giá cho hàng";

	session_start();
	header("Content-Type: text/xml");
	echo "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>";
	echo "<$table>";
	if($_SESSION["un"]=="")
	{
		echo "<status>fail</status>";
		echo "<count>0</count>";
		echo "<message>Chưa đăng nhập !</message>";
	}
	else 
	{
		$result=mysql_query("select * from $table $strdk",$conn) or die("select * from $table $strdk");
		echo "<status>ok</status>";
		echo "<count>",mysql_num_rows($result),"</count>";
		echo "<message>OK</message>";	
		while($a=mysql_fetch_array($result))
		{
			echo "<row id='",$a["id"],"'>";
			echo "<cell>",$a["id"],"</cell>";//0
			echo "<cell>",$a["idhang"],"</cell>";//1
			echo "<cell><![CDATA[",date("d-m-Y",strtotime($a["ngay"])),"]]></cell>";//2
			echo "<cell>",number_format($a["dongia"],2,".",","),"</cell>";//3
			echo "<cell>",$a["iddvthang"],"</cell>";//4
			echo "<cell>",$a["chophep"],"</cell>";//5
			echo "<cell><![CDATA[",$a["ngaytao"],"]]></cell>";//6
			echo "<cell><![CDATA[",$a["un"],"]]></cell>";//7

			$tenhang="";
			$rs=mysql_query("select * from hang where id=".$a["idhang"],$conn);
			while($a1=mysql_fetch_array($rs)) $tenhang=$a1["ten"];
			mysql_free_result($rs);
			echo "<cell><![CDATA[",$tenhang,"]]></cell>";//8
			echo "<cell><![CDATA[",date("H:i",strtotime($a["ngay"])),"]]></cell>";//9

			$tendvthang="";
			$rs=mysql_query("select * from dvthang where id=".$a["iddvthang"],$conn) or die("select * from dvthang where id=".$a["iddvthang"]);
			while($a1=mysql_fetch_array($rs)) $tendvthang=$a1["ten"];
			mysql_free_result($rs);
			echo "<cell><![CDATA[",$tendvthang,"]]></cell>";//10

			echo "</row>";
		}
		mysql_free_result($result);
	}

	echo "</$table>";
	include("../../include/dbclose.php");
?>
